//选项卡的单击事件
function TabDiv_OnClick()
{
	SetSelectedTab( this.TabCode ) ;
}

//选项卡的进入事件
function TabDiv_OnMouseover()
{
	SetMouseoverTab(this.TabCode);
}

//选项卡的移出事件
function TabDiv_OnMouseout()
{
	SetMouseoutTab(this.TabCode);
}

//添加选项卡
function AddTab( tabCode, tabText, startHidden )
{
	if ( typeof( oTabs[ tabCode ] ) != 'undefined' )
		return ;

	var eTabsRow = document.getElementById( 'Tabs' ) ;

	var oCell = eTabsRow.insertCell(  eTabsRow.cells.length - 1 ) ;
	oCell.noWrap = true ;

	var oDiv = document.createElement( 'DIV' ) ;

	oDiv.className = 'PopupTab' ;
	oDiv.innerHTML = tabText ;
	oDiv.TabCode = tabCode ;
	oDiv.onclick = TabDiv_OnClick ;  //单击事件
	oDiv.onmouseover = TabDiv_OnMouseover;  //移动事件
	oDiv.onmouseout = TabDiv_OnMouseout;   //移出事件

	if ( startHidden )
		oDiv.style.display = 'none' ;

	eTabsRow = document.getElementById( 'TabsRow' ) ;

	oCell.appendChild( oDiv ) ;

	if ( eTabsRow.style.display == 'none' )
	{
		var eTitleArea = document.getElementById( 'TitleArea' ) ;

		eTitleArea.className = 'PopupTitle' ;

		oDiv.className = 'PopupTabSelected' ;
		eTabsRow.style.display = '' ;

		if ( ! window.dialogArguments.Editor.FCKBrowserInfo.IsIE )
			window.onresize() ;
	}

	oTabs[ tabCode ] = oDiv ;
	oTabs[ tabCode ].Index = oTabs.length - 1 ;
}

//单击事件
function SetSelectedTab( tabCode )
{
	for ( var sCode in oTabs )
	{
		if ( sCode == tabCode )
		{
		  oTabs[sCode].className = 'PopupTabSelected' ;
		  obj = document.getElementById(sCode) ;
          obj.style.display = "";   
		}
		else
		{
			oTabs[sCode].className = 'PopupTab' ;
		    obj = document.getElementById(sCode) ;
            obj.style.display = "none";   
		}
	}

}

//移动事件
function SetMouseoverTab( tabCode )
{
	for ( var sCode in oTabs )
	{
		if (( sCode == tabCode ) && (oTabs[sCode].className != "PopupTabSelected"))
		   oTabs[sCode].className = 'PopupTabMouseover' ;
		else if (oTabs[sCode].className != "PopupTabSelected")
			oTabs[sCode].className = 'PopupTab' ;
	}
}

//移出事件
function SetMouseoutTab( tabCode )
{
	for ( var sCode in oTabs )
	{
		if (oTabs[sCode].className != "PopupTabSelected")
			oTabs[sCode].className = 'PopupTab' ;
	}
} 
